package com.kyk.kktakeaway;

import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;

import java.nio.file.Paths;

public class Code {

//    public static void main(String[] args) {
//        generateCode("jdbc:mysql://localhost:3306/food_delivery_platform", "root", "123456", "com.kyk.kktakeaway");
//    }
    public static void generateCode(String url, String username, String password,String parentPackage) {
        FastAutoGenerator.create(url, username, password)
                .globalConfig(builder -> builder
                        .author("凯")
                        .outputDir(Paths.get(System.getProperty("user.dir")) + "/src/main/java")
                        .commentDate("yyyy-MM-dd")
                )
                .packageConfig(builder -> builder
                        .parent(parentPackage)
                        .entity("entity")
                        .mapper("mapper")
                        .service("service")
                        .serviceImpl("service.impl")
                        .xml("mapper.xml")
                )
                .strategyConfig(builder -> builder
                        .entityBuilder()
                        .enableLombok()
                )
                .templateEngine(new FreemarkerTemplateEngine())
                .execute();
    }
}
